#include "userdel.h"

int do_delete(user_session_t *user_session)
{
    char sql[4096]={0};
    sprintf(sql,"update users set is_deleted=1 where username ='%s';",user_session->username);
    printf("%s\n",sql);
    int qres=mysql_query(user_session->conn,sql);
    if(qres!=0)
    {
        fprintf(stderr,"%s:%s\n","mysql_query",mysql_error(user_session->conn));
        return -1;
    }
    tlv_msg_t msg;
    bzero(&msg,sizeof(tlv_msg_t));
    char value[]="user delete success!";
    msg.hdr.length=strlen(value);
    tlv_create(&msg,LOGIN_IN,msg.hdr.length,value);
    tlv_send(user_session->netfd,&msg);
    printf("user delete success!\n");
    return 0;
}
